
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>docker23 自定义网络 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="docker24 SpringBoot 微服务打包Docker镜像.html" />
    
    
    <link rel="prev" href="docker22 容器互联.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="docker01 docker能干嘛.html">
            
                <a href="docker01 docker能干嘛.html">
            
                    
                    docker01 docker能干嘛
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="docker02 安装docker.html">
            
                <a href="docker02 安装docker.html">
            
                    
                    docker02 安装docker
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="docker03 docker原理.html">
            
                <a href="docker03 docker原理.html">
            
                    
                    docker03 docker原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="docker04 镜像基本命令.html">
            
                <a href="docker04 镜像基本命令.html">
            
                    
                    docker04 镜像基本命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="docker05 容器基本命令.html">
            
                <a href="docker05 容器基本命令.html">
            
                    
                    docker05 容器基本命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="docker06 常用其他命令.html">
            
                <a href="docker06 常用其他命令.html">
            
                    
                    docker06 常用其他命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="docker07 进入当前正在运行的容器.html">
            
                <a href="docker07 进入当前正在运行的容器.html">
            
                    
                    docker07 进入当前正在运行的容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="docker08 部署nginx.html">
            
                <a href="docker08 部署nginx.html">
            
                    
                    docker08 部署nginx
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="docker09 部署tomcat.html">
            
                <a href="docker09 部署tomcat.html">
            
                    
                    docker09 部署tomcat
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="docker10 可视化面板.html">
            
                <a href="docker10 可视化面板.html">
            
                    
                    docker10 可视化面板
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="docker11 镜像原理.html">
            
                <a href="docker11 镜像原理.html">
            
                    
                    docker11 镜像原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="docker12 commit镜像.html">
            
                <a href="docker12 commit镜像.html">
            
                    
                    docker12 commit镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="docker13 容器数据卷.html">
            
                <a href="docker13 容器数据卷.html">
            
                    
                    docker13 容器数据卷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="docker14 具名挂载和匿名挂载.html">
            
                <a href="docker14 具名挂载和匿名挂载.html">
            
                    
                    docker14 具名挂载和匿名挂载
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="docker15 初始dockerfile.html">
            
                <a href="docker15 初始dockerfile.html">
            
                    
                    docker15 初始dockerfile
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="docker16 数据卷容器.html">
            
                <a href="docker16 数据卷容器.html">
            
                    
                    docker16 数据卷容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="docker17 dockerFile.html">
            
                <a href="docker17 dockerFile.html">
            
                    
                    docker17 dockerFile
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="docker18 dockerFile基本命令.html">
            
                <a href="docker18 dockerFile基本命令.html">
            
                    
                    docker18 dockerFile基本命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="docker19 构建自己的centos.html">
            
                <a href="docker19 构建自己的centos.html">
            
                    
                    docker19 构建自己的centos
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="docker20 发布镜像.html">
            
                <a href="docker20 发布镜像.html">
            
                    
                    docker20 发布镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.22" data-path="docker21 网络详情.html">
            
                <a href="docker21 网络详情.html">
            
                    
                    docker21 网络详情
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.23" data-path="docker22 容器互联.html">
            
                <a href="docker22 容器互联.html">
            
                    
                    docker22 容器互联
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.24" data-path="docker23 自定义网络.html">
            
                <a href="docker23 自定义网络.html">
            
                    
                    docker23 自定义网络
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.25" data-path="docker24 SpringBoot 微服务打包Docker镜像.html">
            
                <a href="docker24 SpringBoot 微服务打包Docker镜像.html">
            
                    
                    docker24 SpringBoot 微服务打包Docker镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.26" data-path="docker25 dockerFile_demo.html">
            
                <a href="docker25 dockerFile_demo.html">
            
                    
                    docker25 dockerFile_demo
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >docker23 自定义网络</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="&#x81EA;&#x5B9A;&#x4E49;&#x7F51;&#x7EDC;">&#x81EA;&#x5B9A;&#x4E49;&#x7F51;&#x7EDC;</h3>
<p>&#x67E5;&#x770B;&#x6240;&#x6709;&#x7684;&#x7F51;&#x7EDC;</p>
<pre><code class="lang-bash">[root@iz8g9301trfnpxz home]<span class="hljs-comment"># docker network ls</span>
NETWORK ID          NAME                DRIVER              SCOPE
68c30b64280c        bridge              bridge              <span class="hljs-built_in">local</span>
e5373821382b        host                host                <span class="hljs-built_in">local</span>
bc64d000f692        none                null                <span class="hljs-built_in">local</span>
</code></pre>
<p>&#x7F51;&#x7EDC;&#x6A21;&#x5F0F;</p>
<table>
<thead>
<tr>
<th style="text-align:center">&#x7F51;&#x7EDC;&#x6A21;&#x5F0F;</th>
<th style="text-align:center">&#x89E3;&#x91CA;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">bridge</td>
<td style="text-align:center">&#x6865;&#x63A5;docker(&#x9ED8;&#x8BA4;,&#x81EA;&#x5DF1;&#x521B;&#x5EFA;&#x4E5F;&#x662F;bridge&#x6A21;&#x5F0F;)</td>
</tr>
<tr>
<td style="text-align:center">none</td>
<td style="text-align:center">&#x4E0D;&#x914D;&#x7F6E;&#x7F51;&#x7EDC;</td>
</tr>
<tr>
<td style="text-align:center">host</td>
<td style="text-align:center">&#x548C;&#x5BBF;&#x4E3B;&#x673A;&#x5171;&#x4EAB;&#x7F51;&#x7EDC;</td>
</tr>
<tr>
<td style="text-align:center">container</td>
<td style="text-align:center">&#x5BB9;&#x5668;&#x7F51;&#x7EDC;&#x8FDE;&#x901A;!(&#x7528;&#x7684;&#x5C11;!&#x5C40;&#x9650;&#x5F88;&#x5927;)</td>
</tr>
</tbody>
</table>
<pre><code class="lang-bash"><span class="hljs-comment"># &#x6211;&#x4EEC;&#x76F4;&#x63A5;&#x542F;&#x52A8;&#x7684;&#x547D;&#x4EE4; --net bridge ,&#x800C;&#x8FD9;&#x4E2A;&#x5C31;&#x662F;&#x6211;&#x4EEC;&#x7684;docker0</span>
[root@iz8g9301trfnpxz home]<span class="hljs-comment"># docker run -d -P --name tomcat01 tomcat</span>
[root@iz8g9301trfnpxz home]<span class="hljs-comment"># docker run -d -P --name tomcat01 --net bridge tomcat</span>
120ae6154cb8a090d7bf43c5b25620fa6913afd1eae5426ec6dc3fb95de1e4b2

<span class="hljs-comment"># docker0 &#x7279;&#x70B9;: &#x9ED8;&#x8BA4;,&#x57DF;&#x540D;&#x4E0D;&#x80FD;&#x8BBF;&#x95EE;,--link&#x53EF;&#x4EE5;&#x6253;&#x901A;&#x8FDE;&#x63A5;!</span>

<span class="hljs-comment"># &#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x81EA;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x7F51;&#x7EDC;! </span>
<span class="hljs-comment"># --driver bridge</span>
<span class="hljs-comment"># --subnet 192.168.0.0/16   192.168.0.2  &#x5B50;&#x7F51;</span>
<span class="hljs-comment"># --gateway 192.168.0.1   &#x7F51;&#x5173;</span>
[root@iz8g9301trfnpxz home]<span class="hljs-comment"># docker network create --driver bridge --subnet 192.168.0.0/16 --gateway 192.168.0.1 mynet</span>
8a651bded67f27601cc17590df67043bad863e8b9e3b8b3f9b636bf8ebbb30f8

[root@iz8g9301trfnpxz home]<span class="hljs-comment"># docker network ls</span>
NETWORK ID          NAME                DRIVER              SCOPE
68c30b64280c        bridge              bridge              <span class="hljs-built_in">local</span>
e5373821382b        host                host                <span class="hljs-built_in">local</span>
8a651bded67f        mynet               bridge              <span class="hljs-built_in">local</span>
bc64d000f692        none                null                <span class="hljs-built_in">local</span>
</code></pre>
<p>&#x67E5;&#x770B;&#x4E00;&#x4E0B;</p>
<pre><code class="lang-bash">[root@iz8g9301trfnpxz home]<span class="hljs-comment"># docker network inspect mynet</span>
[
    {
        <span class="hljs-string">&quot;Name&quot;</span>: <span class="hljs-string">&quot;mynet&quot;</span>,
        <span class="hljs-string">&quot;Id&quot;</span>: <span class="hljs-string">&quot;8a651bded67f27601cc17590df67043bad863e8b9e3b8b3f9b636bf8ebbb30f8&quot;</span>,
        <span class="hljs-string">&quot;Created&quot;</span>: <span class="hljs-string">&quot;2020-08-03T09:57:58.644192346+08:00&quot;</span>,
        <span class="hljs-string">&quot;Scope&quot;</span>: <span class="hljs-string">&quot;local&quot;</span>,
        <span class="hljs-string">&quot;Driver&quot;</span>: <span class="hljs-string">&quot;bridge&quot;</span>,
        <span class="hljs-string">&quot;EnableIPv6&quot;</span>: <span class="hljs-literal">false</span>,
        <span class="hljs-string">&quot;IPAM&quot;</span>: {
            <span class="hljs-string">&quot;Driver&quot;</span>: <span class="hljs-string">&quot;default&quot;</span>,
            <span class="hljs-string">&quot;Options&quot;</span>: {},
            <span class="hljs-string">&quot;Config&quot;</span>: [
                {
                    <span class="hljs-string">&quot;Subnet&quot;</span>: <span class="hljs-string">&quot;192.168.0.0/16&quot;</span>,
                    <span class="hljs-string">&quot;Gateway&quot;</span>: <span class="hljs-string">&quot;192.168.0.1&quot;</span>
                }
            ]
        },
        <span class="hljs-string">&quot;Internal&quot;</span>: <span class="hljs-literal">false</span>,
        <span class="hljs-string">&quot;Attachable&quot;</span>: <span class="hljs-literal">false</span>,
        <span class="hljs-string">&quot;Ingress&quot;</span>: <span class="hljs-literal">false</span>,
        <span class="hljs-string">&quot;ConfigFrom&quot;</span>: {
            <span class="hljs-string">&quot;Network&quot;</span>: <span class="hljs-string">&quot;&quot;</span>
        },
        <span class="hljs-string">&quot;ConfigOnly&quot;</span>: <span class="hljs-literal">false</span>,
        <span class="hljs-string">&quot;Containers&quot;</span>: {},
        <span class="hljs-string">&quot;Options&quot;</span>: {},
        <span class="hljs-string">&quot;Labels&quot;</span>: {}
    }
]
[root@iz8g9301trfnpxz home]<span class="hljs-comment">#</span>
</code></pre>
<blockquote>
<p>&#x7F51;&#x7EDC;&#x8FDE;&#x901A;</p>
</blockquote>
<p>&#x628A;&#x5BB9;&#x5668;&#x8FDE;&#x63A5;&#x5230;&#x7F51;&#x7EDC;&#x4E0A;
<img src="./imgs/&#x5FAE;&#x4FE1;&#x622A;&#x56FE;_20210324135545.png" alt=""></p>
<p><img src="./imgs/&#x5FAE;&#x4FE1;&#x622A;&#x56FE;_20210324135659.png" alt=""></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="docker22 容器互联.html" class="navigation navigation-prev " aria-label="Previous page: docker22 容器互联">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="docker24 SpringBoot 微服务打包Docker镜像.html" class="navigation navigation-next " aria-label="Next page: docker24 SpringBoot 微服务打包Docker镜像">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"docker23 自定义网络","level":"1.24","depth":1,"next":{"title":"docker24 SpringBoot 微服务打包Docker镜像","level":"1.25","depth":1,"path":"docker24 SpringBoot 微服务打包Docker镜像.md","ref":"docker24 SpringBoot 微服务打包Docker镜像.md","articles":[]},"previous":{"title":"docker22 容器互联","level":"1.23","depth":1,"path":"docker22 容器互联.md","ref":"docker22 容器互联.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"docker23 自定义网络.md","mtime":"2021-04-17T06:21:12.856Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-04-17T07:50:48.567Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

